<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>
        .picture{
            background: url(asset/img/01.jpg) no-repeat;
            height: 300px;
            width: 400px;
            margin: 0 auto;
        }
        .picture--break{
            background: url(asset/img/02.jpg) no-repeat;
        }
        .progressBar{
            border: 1px solid #333;
            height: 20px;
            border-radius: 10px;
            width: 200px;
            margin: 0 auto;
            overflow: hidden;
        }
        .progressBar div{
            background: mediumseagreen;
            width: 100%;
            height: 20px;
        }
        .button{
            margin: 10px auto;
            width: 200px;
            text-align: center;
        }
        .button button{
            padding: 5px 10px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="picture" v-bind:class="{'picture--break': isShow}">
            
        </div>
        <div class="progressBar">
            <div v-bind:style="{width:progressBar + '%'}"></div>
        </div>

        <div class="button">
            <button v-on:click="beat" v-show="!isShow">使劲敲</button>
            <button v-on:click="restart">重新开始</button>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                progressBar:100,
                isShow:false
            },
            methods: {
                beat:function(){
                    this.progressBar = this.progressBar - 10;
                    if (this.progressBar == 0) {
                        this.isShow = true;
                        
                    }
                },
                restart:function(){
                    this.progressBar = 100;
                    this.isShow = false;
                }
            },
            computed: {

            }
        })
    </script>
</body>

</html>